import { request } from "@umijs/max"

// 级联选择器数据
export function GetListFnc () {
  return request('categories', {
    method: 'get'
  })
}

// 得到table数据
export function GetAttrFnc (id: number, data: {sel: string}) { 
    return request(`/categories/${id}/attributes?sel=${data.sel}`, {
      method: 'get'
    })
  }

  // 添加 动态参数 静态属性
export function AddParamsFnc (cateId: number, data: {attr_name: string, attr_sel: string}) {
  return request(`/categories/${cateId}/attributes`, {
    method: 'post',
    data: data
  })
}

// 打开编辑盒子获取 动态参数 静态属性
export function ShowEditParamsFnc (cateId: number, id: number, data: {attr_sel: string}) { 
  return request(`/categories/${cateId}/attributes/${id}?attr_sel=${data.attr_sel}`, {
    method: 'get'
  })
}


// 修改对应参数信息
export function EditParamsFnc (cateId: number, attrId: number, data: {attr_name: string, attr_sel: string}) { 
  return request(`/categories/${cateId}/attributes/${attrId}`, {
    method: 'put',
    data: data
  })
}

// 删除参数
export function RemoveParamsFnc (cateId: number, attrId: number) { 
  return request(`/categories/${cateId}/attributes/${attrId}`, {
    method: 'delete'
  })
}

// 展开行 tag添加删除
export function AddDelParamsFnc (cateId: number, attrId: number, data: {attr_name: string, attr_sel: string, attr_vals: any}) { 
    return request(`/categories/${cateId}/attributes/${attrId}`, {
      method: 'put',
      data: data
    })
  }
  